package interfaceWorker;

import java.awt.Component;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import javax.swing.JPanel;

public class WorkerGui extends JPanel implements ActionListener {
	
	private JButton btnBackToMenu, btnNext,btnSavePark, btnMaintenance,btnSetUp;
	//private WorkerFrame wp;
	private Dimension wfs;
	//private WorkerGui wg;
	private WorkerFrame wfg;
	
	private SetupPanel sp = new SetupPanel();

	/**
	 * @wbp.parser.constructor
	 */
	public WorkerGui(Dimension fs,WorkerFrame wf) {
		wfs=fs;
		wfg=wf;
		wfg.setname("Worker Station");
		//setTitle("Worker station");
		//frameSize = new Dimension(500, 500);
		this.setSize(fs);
		this.setLayout(null);
		//this.setDefaultCloseOperation(EXIT_ON_CLOSE);
		
		/*btnBackToMenu = new JButton("Back To Menu");
		btnBackToMenu.setBounds(45, 215, 115, 25);
		getContentPane().add(btnBackToMenu);
		btnBackToMenu.addActionListener(this);
		
		btnNext = new JButton("Next");
		btnNext.setBounds(278, 215, 115, 25);
		getContentPane().add(btnNext);
		btnNext.addActionListener(this);*/
		
		btnSavePark = new JButton("Reserve Spot");
		btnSavePark.setBounds(150, 60, 115, 25);
		this.add(btnSavePark);
		btnSavePark.addActionListener(this);
		
		 btnMaintenance = new JButton("Check Spot Under Maintenance");
		 btnMaintenance.setBounds(150, 180, 250, 25);
		 this.add( btnMaintenance);
		 btnMaintenance.addActionListener(this);
		
		btnSetUp = new JButton("SetUp Parking Lot");
		btnSetUp.setBounds(150, 120, 146, 25); 
		this.add(btnSetUp);
		btnSetUp.addActionListener(this);
		
		this.setVisible(true);


	}

	@Override
	public void actionPerformed(ActionEvent e) {
		// TODO Auto-generated method stub
		
		if(e.getSource() == btnSavePark)
		{
			if(sp.getrawsize()==0)
				JOptionPane.showMessageDialog(this,"You Require to Setup the lot first","OK",JOptionPane.ERROR_MESSAGE);
			else{
			removeAll();
	        add(new ReserveParkingSpotPanel(wfs,wfg));
	        validate();
	        repaint();
			wfg.setname("Reserve Parking Spot");
			}
		}
		if(e.getSource() == btnMaintenance)
		{
			sp = new SetupPanel();
			if(sp.getrawsize()==0)
				JOptionPane.showMessageDialog(this,"You Require to Setup the lot first","OK",JOptionPane.ERROR_MESSAGE);
			//this.setVisible(false);
			//this.add(new MaintanceParkingSpotPanel(wg,wfs));
			else{
			removeAll();
	        add(new MaintanceParkingSpotPanel(wfs,wfg));
	        validate();
	        repaint();
			wfg.setname("Maintance Parking Spot");
			}
		}
		if(e.getSource() == btnSetUp)
		{
			//this.setVisible(false);
			//wp.setContentPane(new SetupPanel(wp,wfs));
			//setTitle("SetUp");
			removeAll();
	        add(new SetupPanel(wfs,wfg));
	        validate();
	        repaint();
	        wfg.setname("Setup");
	        //wp.validate();
	        //wp.repaint();
			
		}
			
		
		
		
	}
}
